package com.welike.shibo.controller.v2.api;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.welike.shibo.eneity.JsonResult;
import com.welike.shibo.eneity.Log;
import com.welike.shibo.service.LogService;
import com.welike.shibo.utils.ResultUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author fangyu
 * @version v1.0.0
 * @since 2019/11/20 5:33 下午
 */
@Slf4j
@Api(value = "日志相关接口")
@RestController
@RequestMapping("/v2/api/log")
public class LogController {

    @Resource
    private LogService logService;

    @RequiresPermissions("log:list")
    @GetMapping("/list")
    public JsonResult list(
            @ApiParam(name = "page", value = "页数", required = false)
            @RequestParam(value = "page", defaultValue = "1", required = false) int page,
            @ApiParam(name = "pageSize", value = "每页条数", required = false)
            @RequestParam(value = "pageSize", defaultValue = "10", required = false)int pageSize
    ) {
        IPage<Log> iPage = logService.queryByAll(page, pageSize);
        return ResultUtils.success("list", iPage);
    }
}
